package org.raymond.iworks.apis.fallbackFactory;

import lombok.extern.slf4j.Slf4j;
import org.raymond.iworks.apis.ITUserRoleServiceApi;
import org.raymond.iworks.apis.common.Result;
import org.raymond.iworks.apis.vo.role.UserRoleVO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ITUserRoleServiceFallbackFactory implements FallbackFactory<ITUserRoleServiceApi> {
    @Override
    public ITUserRoleServiceApi create(Throwable throwable) {
        final String error = throwable.getMessage();
        log.error(error, throwable);
        return new ITUserRoleServiceApi() {
            @Override
            public Result create(UserRoleVO vo) {
                return Result.error(error);
            }

            @Override
            public Result delete(UserRoleVO vo) {
                return Result.error(error);
            }

            @Override
            public Result list(UserRoleVO vo) {
                return Result.error(error);
            }
        };
    }
}
